<?php

/**
 * Template filter form base class.
 *
 * @package    25Mails
 * @subpackage filter
 * @author     fabio.lorenzini@25solutions.com
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseTemplateFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'            => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'language'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'country'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'sender_name'     => new sfWidgetFormFilterInput(),
      'sender_address'  => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'subject'         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'body_txt'        => new sfWidgetFormFilterInput(),
      'body_html'       => new sfWidgetFormFilterInput(),
      'attachment'      => new sfWidgetFormFilterInput(),
      'attachment_name' => new sfWidgetFormFilterInput(),
      'attachment_type' => new sfWidgetFormFilterInput(),
      'cc'              => new sfWidgetFormFilterInput(),
      'bcc'             => new sfWidgetFormFilterInput(),
      'created_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'deleted_at'      => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'name'            => new sfValidatorPass(array('required' => false)),
      'language'        => new sfValidatorPass(array('required' => false)),
      'country'         => new sfValidatorPass(array('required' => false)),
      'sender_name'     => new sfValidatorPass(array('required' => false)),
      'sender_address'  => new sfValidatorPass(array('required' => false)),
      'subject'         => new sfValidatorPass(array('required' => false)),
      'body_txt'        => new sfValidatorPass(array('required' => false)),
      'body_html'       => new sfValidatorPass(array('required' => false)),
      'attachment'      => new sfValidatorPass(array('required' => false)),
      'attachment_name' => new sfValidatorPass(array('required' => false)),
      'attachment_type' => new sfValidatorPass(array('required' => false)),
      'cc'              => new sfValidatorPass(array('required' => false)),
      'bcc'             => new sfValidatorPass(array('required' => false)),
      'created_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'deleted_at'      => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
    ));

    $this->widgetSchema->setNameFormat('template_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Template';
  }

  public function getFields()
  {
    return array(
      'template_id'     => 'Number',
      'name'            => 'Text',
      'language'        => 'Text',
      'country'         => 'Text',
      'sender_name'     => 'Text',
      'sender_address'  => 'Text',
      'subject'         => 'Text',
      'body_txt'        => 'Text',
      'body_html'       => 'Text',
      'attachment'      => 'Text',
      'attachment_name' => 'Text',
      'attachment_type' => 'Text',
      'cc'              => 'Text',
      'bcc'             => 'Text',
      'created_at'      => 'Date',
      'updated_at'      => 'Date',
      'deleted_at'      => 'Date',
    );
  }
}
